//
//  nameTableViewCell.m
//  shuilijuOASystem
//
//  Created by michael on 16/7/13.
//  Copyright © 2016年 czd. All rights reserved.
//

#import "nameTableViewCell.h"
@implementation nameTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
 if (self) {
          self.selectionStyle = UITableViewCellSelectionStyleNone;

//   _label0 = [[UILabel alloc]initWithFrame:CGRectZero];
//    _label0.font = [UIFont systemFontOfSize:16];
//    _label0.backgroundColor= [self randomColor];
//    _label0.textAlignment = NSTextAlignmentCenter;
//    [self.contentView addSubview:_label0];
    
    _label = [[UILabel alloc]init];
    _label.frame = CGRectZero;
      [_label setFont:[UIFont systemFontOfSize:13]];
       [self.contentView addSubview:_label];

    
    _label1 = [[UILabel alloc]init];
    _label1.frame = CGRectZero;
      [_label1 setFont:[UIFont systemFontOfSize:13]];
       [self.contentView addSubview:_label1];
     
       _label2 = [[xlabel alloc]init];
    _label2.frame = CGRectZero;
      [_label setFont:[UIFont systemFontOfSize:13]];
       [self.contentView addSubview:_label2];
     
     
       _button1 = [UIButton buttonWithType:UIButtonTypeCustom];
       [_button1 setImage:[UIImage imageNamed:@"电话-48"] forState:UIControlStateNormal];
       [_button1 addTarget:self action:@selector(action1) forControlEvents:UIControlEventTouchUpInside];
       [self.contentView addSubview:_button1];
     
        _button2 = [UIButton buttonWithType:UIButtonTypeCustom];
       [_button2 setImage:[UIImage imageNamed:@"邮件-48"] forState:UIControlStateNormal];
       [_button2 addTarget:self action:@selector(action2) forControlEvents:UIControlEventTouchUpInside];
       [self.contentView addSubview:_button2];



}

    return self;

}
-(UIColor *) randomColor
{
    CGFloat hue = ( arc4random() % 256 / 256.0 ); //0.0 to 1.0
    CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0,away from white
    CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; //0.5 to 1.0,away from black
    return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
    
}


- (void)layoutSubviews
{
[super layoutSubviews];
//  _label0.frame = CGRectMake(5, 5, 30, 30);
//  _label0.layer.cornerRadius = 15;
//  _label0.layer.masksToBounds = YES;
    _label.frame = CGRectMake(10,2, 50, 40);
//    _label.backgroundColor= [UIColor redColor];
  _label1.frame = CGRectMake(_label.right+10,2, 60, 40);
//      _label1.backgroundColor= [UIColor yellowColor];
      _label2.frame = CGRectMake(_label1.right+10,2,120, 40);
//      _label2.backgroundColor= [UIColor greenColor];
    _label2.text = _dict[@"phone"];
        _button1.frame = CGRectMake(_label2.right+10,2,40, 40);

  _button2.frame = CGRectMake(_button1.right+10,2,40, 40);

//  _label0.text = _dict[@"surname"];
  if (_isNeedRefresh) {
      _label.text = _dict[@"ryxm"];

}else{
  _label.text = _dict[@"name"];

}
  
  _label1.text = _dict[@"duties"];

  
}
- (void)action1{

NSString * phone = [NSString stringWithFormat:@"tel://%@",self.dict[@"phone"]];
NSLog(@"%@",phone);
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phone]];//打电话


}
- (void)action2{

NSString * phone = [
     NSString stringWithFormat:@"sms://%@",self.dict[@"phone"]];
     NSLog(@"%@",phone);
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:phone]];//发短信

}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
